package com.hqyj.crmdemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hqyj.crmdemo.entity.BusinessRecord;
import com.hqyj.crmdemo.entity.Contact;
import com.hqyj.crmdemo.mapper.BusinessRecordMapper;
import com.hqyj.crmdemo.service.IBusinessRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 何万林
 * @since 2022-10-17
 */
@Service
public class BusinessRecordServiceImpl extends ServiceImpl<BusinessRecordMapper, BusinessRecord> implements IBusinessRecordService {

    @Autowired
    BusinessRecordMapper mapper;

    @Override
    public BusinessRecord queryOne(Integer businessId) {
        BusinessRecord businessRecord = mapper.selectById(businessId);
        return businessRecord;
    }

    @Override
    public List<BusinessRecord> queryAll() {
        List<BusinessRecord> businessRecords = mapper.selectList(null);
        return businessRecords;
    }

    @Override
    public List<BusinessRecord> queryOne(QueryWrapper queryWrapper) {
        List<BusinessRecord> businessRecords = mapper.selectList(queryWrapper);
        return businessRecords;
    }

    @Override
    public Boolean add(BusinessRecord businessRecord) {
        int insert = mapper.insert(businessRecord);
        return insert > 0 ? true : false;
    }

    @Override
    public Boolean update(BusinessRecord businessRecord) {
        int update = mapper.updateById(businessRecord);
        return update > 0 ? true : false;
    }

    @Override
    public Boolean delete(Integer businessId) {
        int delete = mapper.deleteById(businessId);
        return delete > 0 ? true : false;
    }
}
